class Animal{
    String name;
    int age;

    static{

        System.out.println("Animal中的static{}");
    }
    {
        System.out.println("Animal中的{}");
    }
    public Animal() {

        System.out.println("Animal()");
    }

    public void eat(){

        System.out.println(name+"正在吃饭");
    }

}
class Dog extends Animal{

    static{
        System.out.println("Dog中的static{}");
    }
    {
        System.out.println("Dog中的{}");
    }
    public Dog() {
        System.out.println("Dog()");
    }

    public void bark(){

        System.out.println(name+"汪汪叫");
    }
}
class Cat extends Animal{


    public void mew(){

        System.out.println(name+"喵喵叫");
    }
}
class Father{
    int a;
    int b;
    int c;

    public void methodA(){

        System.out.println("父类中无参的methodA");
    }

    public void methodB(){
        System.out.println("父类中的methodB");
    }

}
class Son extends Father{
   int a;
   char c;

    //与父类中的func构成重载
   public void methodA(int a){
       System.out.println("子类中带有参数的methodA");
   }
    //与父类中的func构成重写，重写后序会介绍
    public void methodB(){
        System.out.println("子类中的methodB");
    }
   public void methodC(){
       a=100;
       c='y';
       super.a=101;
       b=105;
       methodA();//没有参数，调用父类中的methodA()
       methodA(15);//
       methodB();//直接访问，永远访问的是子类的
       super.methodB();//通过super关键字访问父类成员变量
       System.out.println(a);
       System.out.println(c);
       System.out.println(super.a);
       System.out.println(b);
   }

}
class Base{
    public Base() {

        System.out.println("Base");
    }
}
class Derived extends Base{
      public Derived(){
          //super() 子类构造方法中会默认调用父类的无参构造方法，super()
          //没写时系统会默认加上，且super()必须是子类构造方法的第一条语句
          System.out.println("Derived");
      }
}
public class Text {
    public static void main(String[] args) {
        Dog dog=new Dog();
    }
    public static void main3(String[] args) {
        Derived derived=new Derived();

    }
    public static void mai2(String[] args) {

        Son son=new Son();
        son.methodC();

    }
    public static void main1(String[] args) {
         Dog dog=new Dog();
         Cat cat=new Cat();
         dog.name="七月";
         cat.name="遇见";
         dog.bark();
         cat.mew();
    }
}
